<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/axios.min.js"></script>
    <script src="/html/util.js"></script>
    <script>

            window.onload = function (){
                getUserAccount();
                type();
            }

            var typeId;
            var userId;

            function  type(){
                axios.get("/post/findTypeId",null).then(e =>{
                    typeId = e.data;
                })
            }
            function  getUserAccount(){
                axios.get("/user/getUserAcc",null).then(e =>{
                    var user = e.data;
                    userId = user.id;
                })
            }

            function  addPost(){
            axios.get("/post/addPost",{
                params:{
                    title:$("title").value,
                    content:$("content").value,
                    typeId:typeId,
                    userId:userId,
                }

            }).then(e=>{
                if (e.data=="ok"){
                    location.href="post.html?id="+typeId;
                }
            })

        }


    </script>
</head>
<body>


标题:<input type="text" id="title"><br>

内容:<textarea id="content" style="width: 150px;height: 150px"></textarea><br>

<input type="button" value="发帖子" onclick="addPost()">

</body>
</html>